@import './var.less';

:root {
  --rv-uploader-size: @uploader-size;
  --rv-uploader-icon-size: @uploader-icon-size;
  --rv-uploader-icon-color: @uploader-icon-color;
  --rv-uploader-text-color: @uploader-text-color;
  --rv-uploader-text-font-size: @uploader-text-font-size;
  --rv-uploader-upload-background-color: @uploader-upload-background-color;
  --rv-uploader-upload-active-color: @uploader-upload-active-color;
  --rv-uploader-delete-color: @uploader-delete-color;
  --rv-uploader-delete-icon-size: @uploader-delete-icon-size;
  --rv-uploader-delete-background-color: @uploader-delete-background-color;
  --rv-uploader-file-background-color: @uploader-file-background-color;
  --rv-uploader-file-icon-size: @uploader-file-icon-size;
  --rv-uploader-file-icon-color: @uploader-file-icon-color;
  --rv-uploader-file-name-padding: @uploader-file-name-padding;
  --rv-uploader-file-name-margin-top: @uploader-file-name-margin-top;
  --rv-uploader-file-name-font-size: @uploader-file-name-font-size;
  --rv-uploader-file-name-text-color: @uploader-file-name-text-color;
  --rv-uploader-mask-text-color: @uploader-mask-text-color;
  --rv-uploader-mask-background-color: @uploader-mask-background-color;
  --rv-uploader-mask-icon-size: @uploader-mask-icon-size;
  --rv-uploader-mask-message-font-size: @uploader-mask-message-font-size;
  --rv-uploader-mask-message-line-height: @uploader-mask-message-line-height;
  --rv-uploader-loading-icon-size: @uploader-loading-icon-size;
  --rv-uploader-loading-icon-color: @uploader-loading-icon-color;
  --rv-uploader-disabled-opacity: @uploader-disabled-opacity;
  --rv-uploader-gap: var(--rv-padding-xs);
}

.@{rv-prefix}-uploader {
  position: relative;
  display: inline-block;

  &__wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: var(--rv-uploader-gap);
    padding-bottom: var(--rv-uploader-gap);

    &--disabled {
      opacity: var(--rv-uploader-disabled-opacity);
    }
  }

  &__input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; // to clip file-upload-button
    cursor: pointer;
    opacity: 0;

    &-wrapper {
      position: relative;
    }

    &:disabled {
      cursor: not-allowed;
    }
  }

  &__upload {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: var(--rv-uploader-size);
    height: var(--rv-uploader-size);
    background-color: var(--rv-uploader-upload-background-color);

    &:active {
      background-color: var(--rv-uploader-upload-active-color);
    }

    &--readOnly:active {
      background-color: var(--rv-uploader-upload-background-color);
    }

    &-icon {
      color: var(--rv-uploader-icon-color);
      font-size: var(--rv-uploader-icon-size);
    }

    &-text {
      margin-top: var(--rv-padding-xs);
      color: var(--rv-uploader-text-color);
      font-size: var(--rv-uploader-text-font-size);
    }
  }

  &__preview {
    position: relative;
    cursor: pointer;

    &-image {
      display: block;
      width: var(--rv-uploader-size);
      height: var(--rv-uploader-size);
      overflow: hidden;
    }

    &-delete {
      position: absolute;
      top: 0;
      right: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      width: var(--rv-uploader-delete-icon-size);
      height: var(--rv-uploader-delete-icon-size);
      background-color: var(--rv-uploader-delete-background-color);
      border-radius: 0 0 0 12 * @hd;

      &-icon {
        color: var(--rv-uploader-delete-color);
        font-size: var(--rv-uploader-delete-icon-size);
        transform: scale(0.7) translate(10%, -10%);
      }
    }

    &-cover {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
    }
  }

  &__mask {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--rv-uploader-mask-text-color);
    background-color: var(--rv-uploader-mask-background-color);

    &-icon {
      font-size: var(--rv-uploader-mask-icon-size);
    }

    &-message {
      margin-top: 6 * @hd;
      padding: 0 var(--rv-padding-base);
      font-size: var(--rv-uploader-mask-message-font-size);
      line-height: var(--rv-uploader-mask-message-line-height);
    }
  }

  &__loading {
    width: var(--rv-uploader-loading-icon-size);
    height: var(--rv-uploader-loading-icon-size);
    color: var(--rv-uploader-loading-icon-color);
  }

  &__file {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: var(--rv-uploader-size);
    height: var(--rv-uploader-size);
    background-color: var(--rv-uploader-file-background-color);

    &-icon {
      color: var(--rv-uploader-file-icon-color);
      font-size: var(--rv-uploader-file-icon-size);
    }

    &-name {
      box-sizing: border-box;
      width: 100%;
      margin-top: var(--rv-uploader-file-name-margin-top);
      padding: var(--rv-uploader-file-name-padding);
      color: var(--rv-uploader-file-name-text-color);
      font-size: var(--rv-uploader-file-name-font-size);
      text-align: center;
    }
  }
}
